/**
* @Author: Chenyongfeng
* @email: kunbei.chen@tuya.com
* @LastEditors: Chenyongfeng
* @file name: app_battery.h
* @Description: 
* @Copyright: HANGZHOU TUYA INFORMATION TECHNOLOGY CO.,LTD
* @Company: http://www.tuya.com
* @Date: 2022-02-22 09:38:57
* @LastEditTime: 2022-02-22 09:38:57
*/

#ifndef __APP_BATTERY_H__
#define __APP_BATTERY_H__

#include "app_common.h"

typedef struct {
    UINT32_T cap_first_delay_time;          ///< delay time of first battery percentage capture
    UINT32_T cap_waitting_silence_time;     ///< time to wait for system silence
    UINT32_T cap_max_period_time;           ///< maximum capture period
    UINT16_T cap_max_voltage;               ///< maximum voltage of battery.
    UINT16_T cap_min_voltage;               ///< minimum voltage of battery.
    TUYA_ADC_BASE_CFG_T adc;
} APP_BATTERY_INFO_T;

typedef struct {
    UINT16_T voltage;       ///< battery voltage
    UINT8_T  percent;       ///< percentage of current battery voltage
} APP_BATTERY_TABLE_T;


/**
* @description: 
* @param {type} 
* @return: 
*/
VOID_T app_battery_config_init(APP_BATTERY_INFO_T* bat_info, APP_BATTERY_TABLE_T* table, UINT8_T table_sums);

/**
* @description: call when the device new-join or rejoin.
* @param {type} 
* @return: 
*/
VOID_T app_battery_start(VOID_T);

/**
* @description: 
* @param {type} 
* @return: 
*/
VOID_T app_battery_stop(VOID_T);

/**
* @description: 
* @param {type} 
* @return: 
*/
VOID_T app_battery_update_attribute(UINT8_T ep, UINT8_T attr_val);

/**
* @description: 
* @param {type} 
* @return: 
*/
VOID_T app_battery_update_and_report_attribute(UINT8_T ep, UINT8_T attr_val);

/**
* @description: 
* @param {type} 
* @return: 
*/
VOID_T app_battery_mf_test_start(VOID_T);

/**
* @description: 
* @param {type} 
* @return: 
*/
VOID_T app_battery_report_attribute(UINT8_T ep);


#endif
